home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Columbia Kermit
/
kermit.zip
/
newsgroups
/
misc.20020314-20021006
/
000216_fdc@columbia.edu_Wed Jul 17 11:24:19 EDT 2002.msg
< prev
next >
Wrap
Text File
|
2020-01-01
|
3KB
|
74 lines
Article: 13528 of comp.protocols.kermit.misc
Path: newsmaster.cc.columbia.edu!news.columbia.edu!news-not-for-mail
From: fdc@columbia.edu (Frank da Cruz)
Newsgroups: comp.unix.programmer,comp.protocols.kermit.misc
Subject: Re: FTP and multiple rename
Date: 17 Jul 2002 11:22:36 -0400
Organization: Columbia University
Lines: 57
Message-ID: <ah423s$2um$1@watsol.cc.columbia.edu>
References: <ah3j66$2ct10@intra09.infocamere.it>
NNTP-Posting-Host: watsol.cc.columbia.edu
X-Trace: newsmaster.cc.columbia.edu 1026919357 6272 128.59.39.139 (17 Jul 2002 15:22:37 GMT)
X-Complaints-To: postmaster@columbia.edu
NNTP-Posting-Date: 17 Jul 2002 15:22:37 GMT
Xref: newsmaster.cc.columbia.edu comp.unix.programmer:149197 comp.protocols.kermit.misc:13528
In article <ah3j66$2ct10@intra09.infocamere.it>,
UomoOmbra <ombra@ombra.xxx> wrote:
: I would like to ftp a server and rename all file in a directory to
: filename.old Hw can I do it?
:
It's best done with a scriptable FTP client:
http://www.columbia.edu/kermit/ftpclient.html
Here's a tutorial on FTP scripting:
http://www.columbia.edu/kermit/ftpscripts.html
Here's a script that does what you want:
---(cut here)---
; Kermit FTP script to add ".old" suffix to all files in a server directory.
;
; Requires C-Kermit 8.0 (Unix) or Kermit 95 2.0 (Windows):
; http://www.columbia.edu/kermit/
;
; Change these as appropriate or convert them to command-line parameters.
; See: http://www.columbia.edu/kermit/ckscripts.html for an explanation.
;
define user olga ; Username
define host ftp.xyzcorp.com ; Hostname
define dir invoices ; Remote directory name
define rfs * ; Remote file specification
define tmp filelist ; Local temp file name
; The rest of the script doesn't need to be changed
ftp \m(host) /user:\m(user) ; Open the connection
if fail stop 1 ftp open \m(host) failed ; Check for failure
ftp cd \m(dir) ; CD to remote directory
if fail stop 1 ftp cd \m(dir) failed ; Check for failure
ftp mget /namelist:\m(tmp) \m(rfs) ; Get list of filenames
if fail stop 1 ftp mget /namelist failed ; Check for failure
fopen /read \%c \m(tmp) ; Open the namelist file
if fail stop 1 Open \m(tmp) failed: \f_errmsg() ; Check for failure
.\%n = 0 ; Initialize file counter
set flag off ; Error indication
while not flag { ; Loop through files
fread \%c filename ; Read next filename
if fail break ; Failure is EOF
increment \%n ; Count the file
echo \%n. \m(filename) ; Give feedback
ftp rename \m(filename) \m(filename).old ; Rename this file
if fail set flag on ; Check for failure
}
ftp dir ; Done - Show remote files
ftp bye ; Disconnect from server
if flag stop 1 ftp rename failed: \m(filename) ; Report any failure
echo Files renamed: \%n ; Or report success
end